/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.pucp.dp1.TSPSolution.view;

import javax.swing.JPanel;
import pe.edu.pucp.dp1.TSPSolution.view.componentes.Index;

/**
 *
 * @author walter
 */
public class Frm_ConsultarCliente extends javax.swing.JPanel {

    /**
     * Creates new form Frm_ConsultarCliente
     */
    public Frm_ConsultarCliente() {
        initComponents();
        this.tblBuscarCliente.setVisible( false ) ;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        lblNombres = new javax.swing.JLabel();
        txtNombres = new javax.swing.JTextField();
        txtApellidos = new javax.swing.JTextField();
        lblApellidos = new javax.swing.JLabel();
        lblDocIdentidad = new javax.swing.JLabel();
        txtDocIdentidad = new javax.swing.JTextField();
        btnBuscarCliente = new javax.swing.JButton();
        btnCancelarBuscarCliente = new javax.swing.JButton();
        btnLimpiarBuscarCliente = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblBuscarCliente = new javax.swing.JTable();
        btnRegistrarCliente = new javax.swing.JButton();
        btnModificarCliente = new javax.swing.JButton();
        btnDarBajaCliente = new javax.swing.JButton();

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Buscar Cliente"));

        lblNombres.setText("Nombres");

        lblApellidos.setText("Apellidos");

        lblDocIdentidad.setText("Doc. Identidad");

        btnBuscarCliente.setText("Buscar");
        btnBuscarCliente.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnBuscarClienteMouseReleased(evt);
            }
        });

        btnCancelarBuscarCliente.setText("Cancelar");
        btnCancelarBuscarCliente.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnCancelarBuscarClienteMouseReleased(evt);
            }
        });

        btnLimpiarBuscarCliente.setText("Limpiar");
        btnLimpiarBuscarCliente.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnLimpiarBuscarClienteMouseReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(39, 39, 39)
                        .addComponent(btnBuscarCliente))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblNombres)
                            .addComponent(lblDocIdentidad)
                            .addComponent(lblApellidos))))
                .addGap(27, 27, 27)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(txtNombres)
                        .addComponent(txtApellidos)
                        .addComponent(txtDocIdentidad, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(btnLimpiarBuscarCliente)
                        .addGap(33, 33, 33)
                        .addComponent(btnCancelarBuscarCliente)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblNombres)
                        .addGap(18, 18, 18)
                        .addComponent(lblApellidos)
                        .addGap(22, 22, 22)
                        .addComponent(lblDocIdentidad))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(txtNombres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(36, 36, 36))
                            .addComponent(txtApellidos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtDocIdentidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnBuscarCliente)
                    .addComponent(btnCancelarBuscarCliente)
                    .addComponent(btnLimpiarBuscarCliente))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tblBuscarCliente.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"1", "Juan José", "Perez Lopez", "12345678"},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Código", "Nombres", "Apellidos", "Doc. Identidad"
            }
        ));
        jScrollPane1.setViewportView(tblBuscarCliente);

        btnRegistrarCliente.setText("Nuevo");
        btnRegistrarCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRegistrarClienteActionPerformed(evt);
            }
        });

        btnModificarCliente.setText("Editar");
        btnModificarCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarClienteActionPerformed(evt);
            }
        });

        btnDarBajaCliente.setText("Eliminar");
        btnDarBajaCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDarBajaClienteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnRegistrarCliente)
                .addGap(52, 52, 52)
                .addComponent(btnModificarCliente)
                .addGap(54, 54, 54)
                .addComponent(btnDarBajaCliente)
                .addGap(62, 62, 62))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnRegistrarCliente)
                    .addComponent(btnModificarCliente)
                    .addComponent(btnDarBajaCliente))
                .addContainerGap(35, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnBuscarClienteMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnBuscarClienteMouseReleased
        // TODO add your handling code here:
        String nombres = txtNombres.getText() ;
        String apellidos = txtApellidos.getText() ;
        String docIdentidad = txtDocIdentidad.getText() ;
        buscar( nombres , apellidos , docIdentidad ) ;
    }//GEN-LAST:event_btnBuscarClienteMouseReleased

    private void btnLimpiarBuscarClienteMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnLimpiarBuscarClienteMouseReleased
        // TODO add your handling code here:
        limpiar() ;
    }//GEN-LAST:event_btnLimpiarBuscarClienteMouseReleased

    private void btnCancelarBuscarClienteMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCancelarBuscarClienteMouseReleased
        // TODO add your handling code here:
        cerrar() ;
    }//GEN-LAST:event_btnCancelarBuscarClienteMouseReleased

    private void btnRegistrarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegistrarClienteActionPerformed
        // TODO add your handling code here:
        Frm_RegistrarCliente frm_registrarCliente = new Frm_RegistrarCliente() ;
        cambiarVista( frm_registrarCliente ) ;
    }//GEN-LAST:event_btnRegistrarClienteActionPerformed

    private void btnModificarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarClienteActionPerformed
        // TODO add your handling code here:
        Frm_ModificarCliente frm_modificarCliente = new Frm_ModificarCliente() ;
        cambiarVista( frm_modificarCliente ) ;
    }//GEN-LAST:event_btnModificarClienteActionPerformed

    private void btnDarBajaClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDarBajaClienteActionPerformed
        // TODO add your handling code here:
        Frm_DarBajaCliente frm_darBajaCliente = new Frm_DarBajaCliente() ;
        cambiarVista( frm_darBajaCliente ) ;
    }//GEN-LAST:event_btnDarBajaClienteActionPerformed

    private void cambiarVista( JPanel panel ){
        ((Index)(this.getTopLevelAncestor())).changeContentPane( panel );
    }
    
    private void buscar( String nombres , String apellidos , String docIdentidad ){
        // falta completar
        mostrarBusqueda() ;
    }
    
    private void mostrarBusqueda(){
        this.tblBuscarCliente.setVisible( true ) ;
    }
    
    private void limpiar(){
        txtNombres.setText( "" ) ;
        txtApellidos.setText( "" ) ;
        txtDocIdentidad.setText( "" ) ;
        tblBuscarCliente.setVisible( false ) ;
    }
    
    private void cerrar(){
        this.setVisible( false ) ;
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuscarCliente;
    private javax.swing.JButton btnCancelarBuscarCliente;
    private javax.swing.JButton btnDarBajaCliente;
    private javax.swing.JButton btnLimpiarBuscarCliente;
    private javax.swing.JButton btnModificarCliente;
    private javax.swing.JButton btnRegistrarCliente;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblApellidos;
    private javax.swing.JLabel lblDocIdentidad;
    private javax.swing.JLabel lblNombres;
    private javax.swing.JTable tblBuscarCliente;
    private javax.swing.JTextField txtApellidos;
    private javax.swing.JTextField txtDocIdentidad;
    private javax.swing.JTextField txtNombres;
    // End of variables declaration//GEN-END:variables
}
